package o;

import android.content.Context;
import android.os.SystemClock;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.huawei.appmarket.framework.widget.uxwidget.topbanner.TopBanner;
import com.huawei.appmarket.service.store.awk.bean.BannerV9CardBean;
import com.huawei.hwid.core.constants.HwAccountConstants;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import o.ewm.d;
import o.ewm.h;
import o.ewm.j;

public class ejb extends PagerAdapter {
    private LinkedList<View> ʻ = null;
    private LayoutInflater ʼ;
    private a ʽ;
    private List<BannerV9CardBean> ˊ = new ArrayList();
    private int ˋ = 0;
    private final xd ˎ = new xd(ContentManager.getInstant().getContext().getResources().getDimensionPixelSize(d.ʾॱ));
    protected Context ˏ;
    private long ॱ = 0;
    private List<BannerV9CardBean> ᐝ = null;

    public interface a {
        void ˋ();

        void ˎ();

        void ॱ();
    }

    class b implements OnTouchListener {
        private long ˊ;
        private int ˎ;
        final /* synthetic */ ejb ˏ;

        public b(ejb o_ejb) {
            this.ˏ = o_ejb;
        }

        public boolean onTouch(View view, MotionEvent motionEvent) {
            switch (motionEvent.getAction()) {
                case 0:
                    this.ˎ = (int) motionEvent.getX();
                    this.ˊ = SystemClock.elapsedRealtime();
                    if (this.ˏ.ʽ != null) {
                        this.ˏ.ʽ.ॱ();
                        break;
                    }
                    break;
                case 1:
                    if (SystemClock.elapsedRealtime() - this.ˊ < 500 && Math.abs(((float) this.ˎ) - motionEvent.getX()) < ((float) this.ˏ.ˋ)) {
                        long currentTimeMillis = System.currentTimeMillis();
                        if (currentTimeMillis - this.ˏ.ॱ > 1000) {
                            this.ˏ.ॱ = currentTimeMillis;
                            if (this.ˏ.ʽ != null) {
                                this.ˏ.ʽ.ˋ();
                            }
                        }
                    }
                    if (this.ˏ.ʽ != null) {
                        this.ˏ.ʽ.ˎ();
                        break;
                    }
                    break;
                case 3:
                    if (this.ˏ.ʽ != null) {
                        this.ˏ.ʽ.ˎ();
                        break;
                    }
                    break;
            }
            return true;
        }
    }

    public static class e {
        public TopBanner ˎ;
    }

    public ejb(Context context, @NonNull List<BannerV9CardBean> list, a aVar) {
        this.ˏ = context;
        ˊ((List) list);
        this.ʻ = new LinkedList();
        this.ʽ = aVar;
        this.ˋ = ViewConfiguration.get(this.ˏ).getScaledTouchSlop();
        this.ʼ = LayoutInflater.from(this.ˏ);
    }

    public boolean ˋ(List<BannerV9CardBean> list) {
        boolean ˊ = ˊ((List) list);
        if (ˊ) {
            notifyDataSetChanged();
        }
        return ˊ;
    }

    private boolean ˊ(List<BannerV9CardBean> list) {
        if (this.ᐝ != null && this.ᐝ.equals(list)) {
            return false;
        }
        this.ˊ.clear();
        if (MinimumFactory.getBoolValue(this.ˏ)) {
            Collections.reverse(list);
        }
        this.ᐝ = list;
        this.ˊ.addAll(this.ᐝ);
        return true;
    }

    public int getCount() {
        return 1000;
    }

    public boolean isViewFromObject(View view, Object obj) {
        return view == obj;
    }

    protected int ˊ() {
        return h.ˊﾟ;
    }

    public Object instantiateItem(ViewGroup viewGroup, int i) {
        e eVar;
        View view;
        BannerV9CardBean bannerV9CardBean = (BannerV9CardBean) this.ˊ.get(i % this.ˊ.size());
        if (this.ʻ.size() == 0) {
            View inflate = this.ʼ.inflate(ˊ(), null);
            TopBanner topBanner = (TopBanner) inflate.findViewById(j.ˈᐨ);
            topBanner.setPadding(azb.ˊ(this.ˏ) / 2, 0, azb.ˏ(this.ˏ) / 2, 0);
            eVar = new e();
            eVar.ˎ = topBanner;
            inflate.setTag(eVar);
            view = inflate;
        } else {
            view = (View) this.ʻ.removeFirst();
            eVar = (e) view.getTag();
        }
        view.setTag(j.ߺ, Integer.valueOf(i));
        view.setTag(j.ٴ, bannerV9CardBean);
        ˏ(bannerV9CardBean, eVar.ˎ);
        viewGroup.addView(view);
        return view;
    }

    public void destroyItem(ViewGroup viewGroup, int i, Object obj) {
        View view = (View) obj;
        viewGroup.removeView(view);
        Object tag = view.getTag();
        if (tag instanceof e) {
            TopBanner topBanner = ((e) tag).ˎ;
            topBanner.ॱ().setImageDrawable(null);
            topBanner.ˋ().setImageDrawable(null);
            topBanner.ˎ().setImageDrawable(null);
            topBanner.ˋ().setOnTouchListener(null);
            topBanner.ॱ().setOnTouchListener(null);
            view.setTag(j.ٴ, null);
        }
        if (this.ʻ.isEmpty()) {
            this.ʻ.add(view);
        } else {
            view.setTag(null);
        }
    }

    private void ˏ(BannerV9CardBean bannerV9CardBean, TopBanner topBanner) {
        eqx.ˏ(topBanner.ॱ(), bannerV9CardBean.ॱˌ(), "bannerv9card", new si[]{this.ˎ});
        ॱ(topBanner.ˋ(), bannerV9CardBean.ˊ(), "iconflag", this.ˎ);
        ॱ(topBanner.ˎ(), bannerV9CardBean.ॱ(), "iconflag", this.ˎ);
        ˋ(topBanner);
        TextView ʻ = topBanner.ʻ();
        Object ˋʻ = bannerV9CardBean.ˋʻ();
        CharSequence v_ = bannerV9CardBean.v_();
        if (ʻ == null) {
            if (dof.ॱ(v_)) {
                v_ = "";
            }
            topBanner.setContentDescription(v_);
        } else if (dof.ॱ(ˋʻ)) {
            ʻ.setVisibility(8);
            if (dof.ॱ(v_)) {
                v_ = "";
            }
            topBanner.setContentDescription(v_);
        } else {
            String str;
            ʻ.setVisibility(0);
            ʻ.setText(ˋʻ);
            StringBuilder stringBuilder = new StringBuilder();
            if (dof.ॱ(v_)) {
                str = "";
            }
            topBanner.setContentDescription(stringBuilder.append(str).append(HwAccountConstants.BLANK).append(ˋʻ).toString());
        }
    }

    private void ॱ(ImageView imageView, String str, String str2, xd xdVar) {
        if (TextUtils.isEmpty(str)) {
            imageView.setVisibility(8);
            return;
        }
        imageView.setVisibility(0);
        eqx.ˏ(imageView, str, str2, new si[]{xdVar});
    }

    private void ˋ(@NonNull TopBanner topBanner) {
        OnTouchListener bVar = new b(this);
        topBanner.ॱ().setOnTouchListener(bVar);
        topBanner.ˋ().setOnTouchListener(bVar);
    }

    public BannerV9CardBean ˋ(int i) {
        if (i >= 0) {
            return (BannerV9CardBean) this.ˊ.get(i % this.ˊ.size());
        }
        return null;
    }
}
